﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

public partial class Admin_AdminLogin : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {



    }
    /// <summary>
    /// 登陆按钮事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>


    protected void btnLogin_Click(object sender, EventArgs e)
    {
        string userName = txtName.Text;
        string passWord = txtPwd.Text;
        if (string.IsNullOrEmpty(txtName.Text) || string.IsNullOrEmpty(txtPwd.Text))
            return;
        AdminUser objAdminUser = AdminUser.GetAdminUserByUsername_Password(userName, passWord);
        if (objAdminUser == null)
            lb_msg.Text = "用户名或者密码错误！";
        else
        {
            objAdminUser.SetCurrent();
            objAdminUser.LastLoginTime = objAdminUser.LoginTime;
            objAdminUser.LoginTime = System.DateTime.Now;
            objAdminUser.Update();
            if (Request["From"] != null)
            {
                string UrlFrom = HttpUtility.UrlDecode(Request["From"]);
                Response.Redirect(UrlFrom);
            }
            Response.Redirect("/Admin/SY.aspx");
        }
    }
}